package com.chuangsi.project.admin.controller.admin;


import com.chuangsi.framework.web.controller.BaseController;
import com.chuangsi.framework.web.domain.ResultObject;
import com.chuangsi.framework.web.page.TableDataInfo;
import com.chuangsi.project.admin.dto.admin.defeat.DefeatIdDto;
import com.chuangsi.project.admin.dto.admin.defeat.ReqDefeatPageDto;
import com.chuangsi.project.admin.dto.admin.defeat.ReqFollowUpRecordsAddDto;
import com.chuangsi.project.admin.dto.admin.defeat.ResDefeatPageDto;
import com.chuangsi.project.admin.service.DefeatService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 战败记录 前端控制器
 * </p>
 *
 * @author 
 * @since 2024-05-10
 */
@Api(tags="战败记录")
@RestController
@RequestMapping("/adminApi/defeat")
public class DefeatController  extends BaseController {

    @Autowired
    private DefeatService defeatService;

    @ApiOperation(value = "分页查询",notes = "ywb")
    @GetMapping("/pageQuery")
    public TableDataInfo<ResDefeatPageDto> pageQuery(ReqDefeatPageDto dto){
        startPage();
        List<ResDefeatPageDto> list = defeatService.pageQuery(dto);
        return getDataTable(list);
    }

    @ApiOperation(value = "导出", notes = "ywb")
    @GetMapping("/export")
    public void export(ReqDefeatPageDto dto, HttpServletResponse response) {
        defeatService.export(dto,response);
    }

    @ApiOperation(value = "添加回访记录", notes = "ywb")
    @PostMapping("/addFollowUpRecords")
    public ResultObject<Void> addFollowUpRecords(@RequestBody @Validated ReqFollowUpRecordsAddDto req) {
        defeatService.addFollowUpRecords(req);
        return ResultObject.ok("添加回访记录成功");
    }

    @ApiOperation(value = "删除回访记录",notes = "ywb")
    @PostMapping("/delDefeat")
    public ResultObject<Void> delDefeat(@RequestBody @Validated DefeatIdDto req){
        defeatService.delDefeat(req.getDefeatId());
        return ResultObject.ok("删除成功");
    }

}
